#!/usr/bin/python
# -*- coding: UTF-8 -*-
import time
import requests
import json
def time_parse(timeStamp):
    localTime = time.localtime(timeStamp)
    strTime = time.strftime("%Y-%m-%d %H:%M:%S", localTime)
    print(strTime)

# 向上/向下/向左/向右/确定/暂停/自动
def test_nlu():
    info = "明天早上八点打开机顶盒"
    url = "http://hakudl.chinaeast2.cloudapp.chinacloudapi.cn:42687/hakuNLP?user_input={info}".format(info=info)
    res = requests.get(url)
    if res.status_code == 200:
        result = res.text
        print(result)
        res = json.loads(result)
        if 0==res.get("code"):
            par = res.get("result").get("semantics").get("request").get("param")
            if "时间" in par:
                time_parse(par.get("时间"))

test_nlu()



